package com.sinopec.siam.provisioning.filter;


import com.sinopec.siam.apache.log4j.Logger;
import com.sinopec.siam.provisioning.handle.SimpleProvisioningEventListener;
import com.sinopec.siam.provisioning.timer.ProvisioningEventSubscriberTimer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class MsgFilter implements ServletContextListener {
	/** Class logger. */
	private final Logger log = Logger.getLogger(MsgFilter.class);


	@Override
	public void contextInitialized(ServletContextEvent servletContextEvent) {
		log.info("================>[Filter]准备开始接收消息");
		ProvisioningEventSubscriberTimer provisioningEventSubscriberTimer=ProvisioningEventSubscriberTimer.getInstance(new SimpleProvisioningEventListener());
		log.info(provisioningEventSubscriberTimer);
		try{
			provisioningEventSubscriberTimer.start();
			log.info("================>[Filter]自动开始接收消息.");
		}catch(IllegalThreadStateException e){
			log.error(e);
		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent servletContextEvent) {

	}
}
